#include <iostream>
using namespace std;
int num = 0;
void print(int chessBox[][8]){
	for(int i = 0;i < 8;i++){
		for(int j = 0;j < 8;j++)
			cout << chessBox[i][j] << " ";
		cout << endl;
	}
}
bool canPutChess(int chessBox[][8],int row,int col){
	for(int i = 0;i < 8;i++)
		for(int j = 0;j < 8;j++)
			if(chessBox[i][j] != 0 && (i == row || j == col || abs(i - row) == abs(j - col)))
				return false;
	return true;
}
void Queen(int chessBox[][8],int row){
	if(row == 8){
		cout <<"--------------------------------"<<++num<<"----------------------------------"<<endl;
		print(chessBox);
	}
	for(int i = 0;i < 8;i++){
		if(canPutChess(chessBox,row,i)){
			chessBox[row][i] = row+1;
			Queen(chessBox,row+1);
			chessBox[row][i] = 0;
		}
	}
}
void main(){
	int chessBox[8][8];
	for(int i = 0;i < 8;i++)
		for(int j = 0;j < 8;j++)
			chessBox[i][j] = 0;
	Queen(chessBox,0);
	system("pause");
}